home *** CD-ROM | disk | FTP | other *** search
/ Netware Super Library / Netware Super Library.iso / pgm_tool / lu62 / rmfmh5.c < prev    next >
C/C++ Source or Header  |  1995-07-03  |  5KB  |  194 lines

  1.  /********************************************************
  2.  *                                                       *
  3.  *                    RMFMH5                             *
  4.  *              processing the FMH-5 by RM               *
  5.  *                                                       *
  6.  * INPUT : "fmhcom" record from PS.                      *
  7.  *                                                       *
  8.  * OUTPUT: the "cma" record to PS.                       *
  9.  *                                                       *
  10.  * CopyRight 1995. Nicholas Poljakov all rights reserved.*
  11.  ********************************************************/
  12. #include <state1.h>
  13. #include <fmhcom.h>
  14. #include <tcb.h>
  15. #include <rcb.h>
  16. #include <scb.h>
  17. #include <fmh5.h>
  18. #include <lucb.h>
  19. #include <arcb.h>
  20. #include <rcballoc.h>
  21. #include <partner.h>
  22. #include <mode.h>
  23. #include <psp.h>
  24. #include <rpl.h>
  25. #include <memory.h>
  26. #include <string.h>
  27. #include <malloc.h>
  28. #include <stdio.h>
  29.  
  30. extern struct psp psp_ini;
  31. unsigned long attacheck(void *);
  32. int psrm(int, void *, void *);
  33.  
  34. unsigned long rmfmh5(s_ptr, ar)
  35. char *s_ptr;
  36. struct cma { /* RM fills this structure */
  37.              struct tcb *p_tcb;
  38.              struct rcb *p_rcb;
  39.            } *ar;
  40. {
  41.     struct tcb *p_tcb;
  42.     struct tcb *temp_tcb;
  43.     struct rcb *p_rcb;
  44.     struct scb *p_scb;
  45.     struct lucb *p_lucb;
  46.     struct fmhcom *p_fmh;
  47.     struct FMH5 *p_fmh5;
  48.     struct pnlu *p_pnlu;
  49.     struct mode *p_mode;
  50.     struct rpl  *p_rpl;
  51.     struct id {
  52.                  char id_n[4];
  53.                  unsigned long id_id;
  54.               } id_ar;
  55.     struct arcb a_rcb;
  56.     struct rcballoc rcb_a;
  57.     char *p;
  58.     unsigned long sense;
  59.     char name[8];
  60.     unsigned int code;
  61.     int i, cnt;
  62.  
  63. #if OS_TYPE == 1
  64. /*********  Trace facility **********/
  65. unsigned int rtype;   /* type of record */
  66. unsigned int pnum;    /* point number */
  67. char pname[8];        /* name of module */
  68. char *drec;           /* record for dump */
  69. int  lenr;            /* record length */
  70.  
  71. rtype = INPROC;
  72. strcpy(pname, "rmfmh5");
  73. pnum = 1;
  74. drec = ar;
  75. lenr = 10;
  76. gtf(rtype, pname, pnum, drec, lenr);
  77. /***********************************/
  78. #endif
  79.  
  80.     p_fmh = s_ptr;
  81.  
  82.     p = p_fmh -> ru;
  83.     if ((sense = attacheck(p)) != OK) {
  84.         goto Ret;
  85.     }
  86.  
  87.     /*
  88.      * Seek SCB for that LU_NAME
  89.      */
  90.  
  91.     p_lucb = psp_ini.lucb_list_ptr;
  92.     p_scb = p_fmh -> p_scb;
  93.  
  94.     /*
  95.      *  Allocate TCB and RCB.
  96.      */
  97.     if (p_scb -> use != FREE) {
  98.         sense = 0x1008600b; /* parallel-session not allow !!!*/
  99.         goto Ret;
  100.     }
  101.     p_scb -> use = IN_USE;
  102.     if (p_lucb -> cur_tps == p_lucb -> max_tps) {
  103.         sense = 0x084b6031; /* Allocation_error--Trans_pgm_not_aval_retry */
  104.         goto Ret;
  105.     }
  106.     if ((p_tcb = calloc(1, sizeof(struct tcb))) == NULL) {
  107.         sense = 0x1008600b; /* SCB was not found */
  108.         goto Ret;
  109.     }
  110.     p_lucb -> cur_tps++;
  111.     if (p_lucb -> tcb_list_ptr == NULL) {
  112.        p_lucb -> tcb_list_ptr = p_tcb;
  113.     }
  114.     else
  115.     {
  116.        temp_tcb = p_lucb -> tcb_list_ptr;
  117.        while (temp_tcb -> next != NULL) {
  118.            temp_tcb = temp_tcb -> next;
  119.        }
  120.        temp_tcb -> next = p_tcb;
  121.        p_tcb -> prev = temp_tcb;
  122.     }
  123.     p_tcb -> p_lucb = p_lucb;
  124.  
  125.     /* Set tcb_id */
  126.  
  127.     memcpy(id_ar.id_n, "TPxx", 4);
  128.     id_ar.id_id = p_tcb;
  129.     memcpy(p_tcb -> tcb_id, &id_ar, 8);
  130.  
  131.     /* Set tp_name */
  132.  
  133.     p_fmh5 = p_fmh -> ru;
  134.     p = &(p_fmh5 -> tpname);
  135.     cnt = p_fmh5 -> lntpn;
  136.     memset(p_tcb -> tp_name, 0, 64);
  137.     for (i = 0; i < cnt; i++) {
  138.         p_tcb -> tp_name[i] = *(p + i);
  139.     }
  140.  
  141.     /* Fill the ALLOCATE_RCB record */
  142.  
  143.     memcpy(a_rcb.lu_name, p_fmh -> lu_name, 8);
  144.     a_rcb.p_tcb = p_tcb;
  145.     /*
  146.      * Seek partner_lu
  147.      */
  148.     p_pnlu = p_lucb -> pluptr;
  149.     while (p_pnlu != NULL) {
  150.         p_mode = p_pnlu -> m_ptr;
  151.         if (memcmp(p_pnlu -> lu_name, a_rcb.lu_name, 8) == 0) {
  152.             goto here_you_are;
  153.         }
  154.         p_pnlu = p_pnlu -> next;
  155.     }
  156.     if (p_pnlu == NULL) {
  157.         sense = 0x1008600b;
  158.         goto Ret;
  159.     }
  160. here_you_are :
  161.     memcpy(a_rcb.mode_name, p_mode -> name, 8);
  162.     /*
  163.      * the ALLOCATE_RCB record is complete.
  164.      */
  165.     code = ALLOCATE_RCB;
  166.     psrm(code, &a_rcb, &rcb_a);
  167.     if (rcb_a.rc != OK) {
  168.         sense = 0x1008600b;
  169.         goto Ret;
  170.     }
  171.     /*
  172.      * Fill "cma" structure.
  173.      */
  174.     ar -> p_tcb = p_tcb;
  175.     ar -> p_rcb = rcb_a.rcb_ptr;
  176.  
  177.     /*
  178.      * Set pointer to RCB in SCB
  179.      */
  180.     p_scb -> p_rcb = rcb_a.rcb_ptr;
  181.     p_rcb = rcb_a.rcb_ptr;
  182.     p_rcb -> conv_state = Rcv;   /* New RCB in receive state */
  183.     p_rcb -> p_scb = p_scb;      /* Link to SCB */
  184.     p_rpl = p_scb -> p_rpl;
  185.     p_rcb -> p_partner = p_pnlu; /* Pointer to Partner_LU */
  186.     p_rcb -> sess_corl = p_rpl -> arg;
  187.     /*
  188.      * Set the sense data and return
  189.      */
  190.     sense = 0x00000000;
  191. Ret:
  192.     return(sense);
  193. }
  194.